<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 17-11-1
 * Time: 下午1:21
 */

namespace wodrow\models;

use ActiveRecord\Model;
use wodrow\tools\Db;

/**
 * This is the model class for table "dyhl_order_log".
 *
 * @property integer $log_id
 * @property integer $log_uid
 * @property string $log_action
 * @property integer $log_related_id
 * @property string $log_explain
 * @property string $log_status
 * @property integer $log_dateline
 */
class OrderLog extends Model
{
    public static $table_name = 'dyhl_order_log';

    public function yii_attributeLabels()
    {
        return array(
            'log_id' => 'Log ID',
            'log_uid' => '操作人ID',
            'log_action' => '动作',
            'log_related_id' => '相关ID',
            'log_explain' => '说明',
            'log_status' => 'Log Status',
            'log_dateline' => '时间',
        );
    }

    /**
     * @param $where
     * @return self
     */
    public static function findOne($where)
    {
        $models = self::find('all', array('conditions' =>Db::getConditions($where)));
        if (count($models)>1){
            throw new \ErrorException('不能有多个');
        }
        /**
         * @var self $model
         */
        $model = $models[0];
        return $model;
    }
}